package com.exahq.common.lang;

import lombok.Data;

import java.io.Serializable;

    @Data
    public class Result implements Serializable {
         private String code;//200是正常，//200表示异常
         private String msg;
         private Object data;

        /**
         * 操作成功
         * @param data
         * @return
         */
         public static Result succ(Object data) {
            Result m = new Result();
            m.setCode("0");
            m.setData(data);
            m.setMsg("操作成功");
            return m;
        }

    public static Result succ(String mess, Object data) {
            Result m = new Result();
            m.setCode("0");
            m.setData(data);
            m.setMsg(mess);
            return m;
    }

        /**
         * 操作异常
         * @param mess
         * @return
         */
    public static Result fail(String mess) {
             Result m = new Result();
             m.setCode("-1");
             m.setData(null);
             m.setMsg(mess);
             return m;
 }
    public static Result fail(String mess, Object data) {
            Result m = new Result();
            m.setCode("-1");
            m.setData(data);
            m.setMsg(mess);
            return m;
    }
}

